import {
	RECORD_USERINFO,
	DELETE_ITEM,
	ADD_ITEM,
	ADD_PLATFORMITEM,
	PLATFORMSTUTAS,
	DELETE_PLATFORMITEM,
	CHANGEPAGE,
	INNITPAGE,
	CHANGEDYNAME,
	CHANGEACTIVE,
	CHANGEISIN,
	ADDOPITION,
	SETLOCALSTORAGE
} from './mutation-types.js'

const setStore = (name, content) => {
	if (!name) return;
	if (typeof content !== 'string') {
		content = JSON.stringify(content);
	}
	window.localStorage.setItem(name, content);
}
const getStore = name => {
	if (!name) return;
	return window.localStorage.getItem(name);
}
export default {
	// 记录用户信息
	// 注意这里有些方法是不用的
	[RECORD_USERINFO](state, info) {
		state.userInfo = info;
		state.login = true;
		setStore('user_id', info.user_id);
	},

	[DELETE_ITEM](state,index){
		state.vinData.splice(index,1);
	},

	[DELETE_PLATFORMITEM](state,index){
		state.platformAccess.splice(index,1);
	},

	[ADD_ITEM](state,data){
		state.vinData=data;
	},

	[ADD_PLATFORMITEM](state,data){
		state.platformAccess = data;
	},

	[PLATFORMSTUTAS](state,tpm){
		state.platformAccess[tpm.index].stutas=tpm.stutas;
	},

	[CHANGEPAGE](state,page){
		state.pageTpm.pageIndex = page;
	},

	[INNITPAGE](state){
		state.pageTpm={
			pageIndex:1,
	        pageSize:10,
	        vds:''
		}
	},

	[CHANGEDYNAME](state,path){
		state.dynameicTags.push(option);
	},

	[CHANGEACTIVE](state,path){
		state.active1 = path
	},

	[CHANGEISIN](state,stutas){
		state.isIn = stutas;
	},

	[ADDOPITION](state,opition){
		state.opition = opition;
	},

	[SETLOCALSTORAGE](state,context){
		state.token=context.context
	}

}